module.exports = {
    CreateClient,
    Login
}
const oicq = require('oicq');
const account = config.client.qq_number;
const password = config.client.password;

let client;

/** 创建客户端 */
function CreateClient(){
    client = oicq.createClient(account, {
        platform: config.client.platform
    });
    client.on('system.online',()=>{
        console.log('Client Start!');
    });
    return client;
}

/** 客户端登录 */
function Login(){
    switch (config.client.login_method){
        case 'qrcode':
            client.on('system.login.qrcode',function (e){
                process.stdin.once("data",()=>{
                    this.login();
                })
            }).login();
            break;
        case 'password':
            client.on("system.login.slider", function (e) {
                console.log("输入ticket：")
                process.stdin.once("data", ticket => this.submitSlider(String(ticket).trim()))
            }).login("password")
            break;
        default:
            throw new Error("未知的登录方式");
    }
}